BigDFT.Interop.DNAviewerInterop module

A module to extend the output by dna_feature_viewer.

plot_field_vals(record, ax, xlim)[source]

Plot all the field data available in the same axis.

plot_one_field_vals(ax, xrange, field_vals, kind='bar', specs={}, errors=None, kind_specs={}, **kwargs)[source]

Plot the data in the axis with their own specification.

restrict_features(features, groups)[source]

Crop the features in the provided groups.

class SequenceRecord(sequence, start_index=1, line_length=None)[source]

Representation of a Sequence in term of a dna_feature_viewer record.

Parameters:
  • sequence (str) – string to represent.

  • start_index (int) – integer indicating the residue id of the starting point.

  • line_length (int) – number of residues to be represented in the line

append_feature(feature, label='')[source]

Insert a dictionary of colors.

Parameters:
  • features (dict) – dictionary of features to be plotted. each dictionary key is the name of the features, and the values are a dictionary of the form {(start_index, end_index): color} where start and end indices are calculated taking into account the start_index.

  • label (str) – label of the feature

append_sequence_field(field_vals, label='', errors=None, array_kwargs={}, **kwargs)[source]

Introduce a sequence field to be plot.

Parameters:
  • field_vals (array-like) – values to be represented, in the order of sequence residues.

  • errors (array-like) – errorbar on to be represented, in the order of sequence residues.

  • label (str) – label of the values, to be put in the legend.

  • array_kwargs (dict) – dictionary of kargs whose values are arrays of the same length of field_vals

  • **kwargs – keyword arguments to be employed in the plot_one_field_vals function.

define_interesting_chunks(chunks)[source]

Introduce the chunks to be plotted separately.

Parameters:

chunks (list) – list of tuples (start,end) in the sequence reference. Start index is considered.

define_highlight_regions(regions)[source]

Introduce chunks to be highlighted.

Parameters:

chunks (dict) – tuples (start,end) as keys, and colors in the sequence reference. Start index is considered.

split_sequence_in_groups()[source]

Define the groups in which to split the sequence representation.

set_line_length(line_length)[source]

Define the conditions associated to the limited length in plots.

get_nlines()[source]

Extract the number of lines of the figures.

get_stride()[source]

Get the number of axis per line.

define_axis_grids(**kwargs)[source]

Define the axis on which to plot the groups.

Parameters:

**kwargs – arguments for py:func:matplotlib.pyplot.figure method.

compose_record(**kwargs)[source]

Create the record from the class.

Parameters:

**kwargs – keyword arguments for GraphicRecord.

level_height = 0.275
sequence_level_shrink = 0.7
y_lower_bound = 0.3928571428571429
y_extra_buffer = 1
total_y_buffer = 0.6678571428571429
lb = 0.52
rb = 0.48
height(ft)[source]

Height of the axis for a given number of features.

set_axis_height(ax, hgt)[source]

Impose the total height considering the space for the sequence.

total_height(buffer=True)[source]

Total height of the axis, including (or not) the sequence space.

display(total_height=None, level_offset=0, on_top_of=None)[source]

Represent record information.

Parameters:
  • total_height (float) – size of the axis height.

  • record. (Useful when representing more than one) –

  • level_offset (int) – starting coordinate of the level.

  • on_top_of (SequenceRecord) – base record on top of which to plot the present data. Employ the groups of the base record.

Returns:

(fig, axsd) matplotlib figure and a dictionary of

{line: axs}, where axs is a list of matplotlib axes employed in a given line.

Return type:

tuple

colordict_to_feature(colordict, sequence_fragments, start_index=0, unify_same_colors=False)[source]

Create the feature data starting from a colordict.

Useful for conversion between the native representation method and the sequence one. Merge together residues which ehibit the same color.

Parameters:
  • sequence_fragments (list) – order of the fragments of the sequence.

  • start_index (int) – initial index of the sequence

  • colordict (dict) – dictionary of the feature colors

  • unify_same_colors (bool) – if true create a rectangle for contiguous residues having the same color. Ignore white colors.

Returns:

feature dictionary to be passed into append_feature

Return type:

dict

get_chain_id(frags)[source]

Commodity function to extract the chain id.

get_data_from_field_vals(sys, field_vals, lookup=None)[source]

Extract the actual data from the field_vals keyword.

get_values_and_errors(fv, lookup=None)[source]

Discriminate between values and values with errors.

sys_into_records(sys, features={}, shift={}, chain_labels={}, line_length=80, restrict_to={}, field_vals={})[source]

Transform a BigDFT.BioQM.BioSystem into a list of SequenceRecord.

Parameters:
  • sys (bigDFT.BioQM.BioSystem) – the system to be represented.

  • features (dict) – dictionary of the features to plot. the dictionary can be of the form: {label: feature}, where feature may be either a string to be passed to py:func:~BigDFT.BioQM.BioSystem.fragment_values method or alternatively a colordict. If label contains the keyword highlight then the unify_same_colors approach is applied to the feature.

  • shift (dict) – shift to be applied to each of the chain id.

  • chain_labels (dict) – label to be written in the figure title, per chain.

  • line_length (int) – number of residues par line.

  • restrict_to (dict) – dictionary of chunks to be plot per chain id.

  • field_vals (dict) – {label: {data: field_vals, kwargs: kwargs, specs: specs}} dictionary. Accepts also the {label: field_vals} format. In this latter case, the field vals value may also be a string which can be passed to py:func:~BigDFT.BioQM.BioSystem.fragment_values method.

Returns:

dictionary of {label: SequenceRecord}, one per system sequence.

Return type:

dict

display_records(records, *args, **kwargs)[source]

Display a stack of records.

Parameters:
  • records (list) – dictionary of SequenceRecord objects to be plot one after another.

  • *args – further lists of objects that will be superimposed at the first argument. should have the same number of elements. Their labels are ignored in favour of the first.

  • **kwargs

    keyword arguments, like:

    records_lookup: list of lists indicating which

    record of the first list should be associated to the records of the others. Put None for records which should not be considered in the comparison.

Returns:

list of (fig, axsd) tuples, containing the figure and

the matplotlib axes dictionary employed per sequence.

Return type:

list